package cn.iocoder.yudao.module.handguard.controller.app.userbasetable2;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;

import cn.iocoder.yudao.module.handguard.controller.app.userbasetable2.vo.*;
import cn.iocoder.yudao.module.handguard.dal.dataobject.userbasetable2.UserBaseTable2DO;
import cn.iocoder.yudao.module.handguard.convert.userbasetable2.UserBaseTable2Convert;
import cn.iocoder.yudao.module.handguard.service.userbasetable2.UserBaseTable2Service;

@Tag(name = "小程序 - 保单贷")
@RestController
@RequestMapping("/hutai/user-base-table2")
@Validated
public class UserBaseTable2Controller {

    @Resource
    private UserBaseTable2Service userBaseTable2Service;

    @PostMapping("/create")
    @Operation(summary = "创建保单贷")
    public CommonResult<Long> createUserBaseTable2(@Valid @RequestBody UserBaseTable2CreateReqVO createReqVO) {
        return success(userBaseTable2Service.createUserBaseTable2(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新保单贷")
    public CommonResult<Boolean> updateUserBaseTable2(@Valid @RequestBody UserBaseTable2UpdateReqVO updateReqVO) {
        userBaseTable2Service.updateUserBaseTable2(updateReqVO);
        return success(true);
    }


    @GetMapping("/get")
    @Operation(summary = "获得保单贷")
    public CommonResult<UserBaseTable2RespVO> getUserBaseTable2(Long ui) {
        UserBaseTable2DO userBaseTable2 = userBaseTable2Service.getUserBaseTable2(ui);
        return success(UserBaseTable2Convert.INSTANCE.convert(userBaseTable2));
    }



}
